﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DTO;
using System.Data;

namespace EC21_EDiamond
{
    public partial class MasterHome : System.Web.UI.MasterPage
    {
        public static DataTable tbGioHang = new DataTable();
        public static DataTable tbSanPham = new DataTable();
        public static KhachHangDTO usDTO = new KhachHangDTO();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                rpThuongHieu.DataSource = SanPhamBUS.LoadTH();
                rpThuongHieu.DataBind();

                if (Session["GioHang"] != null)
                {
                    tbGioHang = Session["GioHang"] as DataTable;
                }
                else
                {
                    tbGioHang.Rows.Clear();
                    tbGioHang.Columns.Clear();
                    tbGioHang.Columns.Add("MaSP", typeof(int));
                    tbGioHang.Columns.Add("TenSP", typeof(string));
                    tbGioHang.Columns.Add("Gia", typeof(int));
                    tbGioHang.Columns.Add("SoLuong", typeof(int));
                    tbGioHang.Columns.Add("HinhAnh", typeof(string));
                    tbGioHang.Columns.Add("TongTien", typeof(int),"SoLuong * Gia");
                }
               
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string key = txtSearch.Text.ToString();
            Response.Redirect("./KetQuaTimKiem.aspx?tensp=" + key);
        }
    }
}